package advance.collection;

import java.util.ArrayList;
import java.util.Comparator;

 class Employee implements Comparable<Employee>, Comparator<Employee>{

	public int id;
	public String name;
	public String address;
	
	ArrayList list = new ArrayList();
	
	public Employee(int id,String name,String address) {
		this.id = id;
		this.name = name;
		this.address = address;
	}
	
	
	public Employee() {
		
	}
	
	public void setname(String name){
		this.name = name;
	}
	public String getname(){
		return name;
	}
	
	public void id(int id){
		this.id = id;
	}
	
	public int getId(){
		return id;
	}
	
	public void setAddress(String address){
		this.address = address;
	}
	
	public String getAddress(){
		return address;
	}


	public String toString(){
		return  " Id :" + this.id + " Name :" +this.name + " Address : " + this.address;
				
	}
	
	public void generateRandomArrayList(){
		
		list.add((int)(Math.random()*100));
		list.add((int)(Math.random()*100));
		list.add((int)(Math.random()*100));
		
	}
	
	public void returnArrayList(){
		System.out.println(list.size());
		System.out.println(list);
	}
	
	


	@Override
	public int compareTo(Employee o) {
		
		return name.compareTo(o.getname());
	}


	@Override
	public int compare(Employee ob1, Employee ob2) {
		return ob1.getId()-ob2.getId();
	}
}
 
/*class IdSort implements Comparator<Employee>{

	@Override
	public int compare(Employee ob1, Employee ob2) {
		
		return ob1.getId()-ob2.getId();
	}
	
}*/

class AddressSort implements Comparator<Employee>{

	@Override
	public int compare(Employee ob1, Employee ob2) {
		
		return ob1.getAddress().compareTo(ob2.getAddress());
	}
	
}
